<template>
  <el-dialog
    title="编辑"
    :visible.sync="dialogVisible"
    :before-close="cancelDialog"
    :close-on-click-modal="false"
    custom-class="role-mask"
  >
    <el-form class="form" :rules="rules" :model="dialogInfo">
      <el-form-item label="日期" hidden prop="statisticsDate">
        <el-input
          v-model="dialogInfo.statisticsDate"
          placeholder="请输入"
          :disabled="true"
        />
      </el-form-item>
      <el-row>
        <el-col :span="8">
          <el-form-item label="原有患者" prop="old_in_num">
            <el-input
              v-model="dialogInfo.old_in_num"
              placeholder="请输入"
            />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="现有患者" prop="current_in_num">
            <el-input
              v-model="dialogInfo.current_in_num"
              placeholder="请输入"
            />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="转入患者" prop="new_in_num">
            <el-input
              v-model="dialogInfo.new_in_num"
              placeholder="请输入"
            />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="转出患者" prop="out_num">
            <el-input
              v-model="dialogInfo.out_num"
              placeholder="请输入"
            />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="出院患者" prop="out_exit_num">
            <el-input
              v-model="dialogInfo.out_exit_num"
              placeholder="请输入"
            />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="转科患者:" prop="out_trans_num">
            <el-input
              v-model="dialogInfo.out_trans_num"
              placeholder="请输入"
            />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="死亡患者" prop="out_death_num">
            <el-input
              v-model="dialogInfo.out_death_num"
              placeholder="请输入"
            />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="放弃患者" prop="out_abandon_num">
            <el-input
              v-model="dialogInfo.out_abandon_num"
              placeholder="请输入"
            />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="转院患者:" prop="out_trans_hosp_num">
            <el-input
              v-model="dialogInfo.out_trans_hosp_num"
              placeholder="请输入"
            />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="48小时返回患者:" prop="two_day_in_again_num">
            <el-input
              v-model="dialogInfo.two_day_in_again_num"
              placeholder="请输入"
            />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="cancelDialog_quxiao">取 消</el-button>
      <el-button type="primary" @click="cancelDialog">保 存</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { inOutIcuStatisticsedit } from '@/api/table'
import axios from 'axios'

export default {
  name: 'Index',
  components: {},
  // 父组件 传 过来的 值
  props: {
    dialogVisible: {
      type: Boolean,
      default: false
    },
    dialogInfo: {
      type: Object,
      default: {}
    }
  },
  data() {
    return {
      listSelect: [],
      role: [],
      arr: [],
      rules: {
        old_in_num: [
          { required: true, message: '原有患者不能为空', trigger: 'blur' }
        ],
        current_in_num: [
          { required: true, message: '现有患者不能为空', trigger: 'blur' }
        ],
        new_in_num: [
          { required: true, message: '转入患者不能为空', trigger: 'blur' }
        ],
        out_num: [
          { required: true, message: '转出患者不能为空', trigger: 'blur' }
        ],
        out_exit_num: [
          { required: true, message: '出院患者不能为空', trigger: 'blur' }
        ],
        out_trans_num: [
          { required: true, message: '转科患者不能为空', trigger: 'blur' }
        ],
        out_death_num: [
          { required: true, message: '死亡患者不能为空', trigger: 'blur' }
        ],
        out_abandon_num: [
          { required: true, message: '放弃患者不能为空', trigger: 'blur' }
        ],
        out_trans_hosp_num: [
          { required: true, message: '转院患者不能为空', trigger: 'blur' }
        ],
        two_day_in_again_num: [
          { required: true, message: '48小时返回患者不能为空', trigger: 'blur' }
        ]

      }
    }
  },
  watch: {
    // 监听 弹窗显示， 可以用来写 请求接口
    dialogVisible: function(newVal, oldVal) {
      if (newVal) {
        console.log(newVal)
      }
    }
  },
  created() {},
  mounted() {},
  methods: {
    cancelDialog_quxiao() {
      this.$emit('update:dialogVisible', false)
    },
    // 修改父组件传过来的值
    cancelDialog() {
      this.$emit('update:dialogVisible', false)
      inOutIcuStatisticsedit({
        statisticsDate: this.dialogInfo.statisticsDate,
        oldInNum: Number(this.dialogInfo.old_in_num),
        currentInNum: Number(this.dialogInfo.current_in_num),
        newInNum: Number(this.dialogInfo.new_in_num),
        outNum: Number(this.dialogInfo.out_num),
        outExitNum: Number(this.dialogInfo.out_exit_num),
        outTransNum: Number(this.dialogInfo.out_trans_num),
        outDeathNum: Number(this.dialogInfo.out_death_num),
        outAbandonNum: Number(this.dialogInfo.out_abandon_num),
        outTransHospNum: Number(this.dialogInfo.out_trans_hosp_num),
        twoDayInAgainNum: Number(this.dialogInfo.two_day_in_again_num)
      }).then((res) => {})
    }
  }
}
</script>
<style lang='scss'scoped>
.form {
  padding: 0 10px;
}

.el-form-item__error {
  color: #f56c6c;
  font-size: 12px;
  line-height: 1;
  padding-top: 4px;
  position: absolute;
  top: 100%;
  left: 88px !important;
}
 .role-mask .el-dialog__header {
      border-bottom: 1px solid #e8eaec;
    }

    .role-mask .el-dialog__body {
      padding: 16px 16px 20px;
      color: #606266;
      font-size: 14px;
      word-break: break-all;
    }

    .role-mask .el-dialog__footer{
      border-top: 1px solid #e8eaec;
    }

</style>
